package com.boe.hbd.client.domain;

import java.util.Collection;
import java.util.Set;

import com.boe.hbd.client.annotation.EntityField; 
import com.boe.hbd.client.persistence.EntityMeta;
import com.boe.hbd.client.utils.ChainedMap;

public class BaseEntity extends ChainedMap<String,Object> { 
    private static final long serialVersionUID = 5615886106577389813L;

	public static final String KEY_COLUMN = "_id";
	
	@EntityField(column = KEY_COLUMN)
	protected Long id;

	@EntityField(column = "name")
	protected String name;

	@EntityField(column = "gmt_created")
	protected Long gmtCreated;

	@EntityField(column = "gmt_updated")
	protected Long gmtUpdated;

	@EntityField(column = "created_by")
	protected String createdBy;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getGmtCreated() {
		return gmtCreated;
	}

	public void setGmtCreated(Long gmtCreated) {
		this.gmtCreated = gmtCreated;
	}

	public Long getGmtUpdated() {
		return gmtUpdated;
	}

	public void setGmtUpdated(Long gmtUpdated) {
		this.gmtUpdated = gmtUpdated;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public boolean containsKey(Object key) {
		EntityMeta meta = EntityMeta.getInstance(getClass());
	    return meta.containsKey(key);
    }

	public int size() {
		EntityMeta meta = EntityMeta.getInstance(getClass()); 
	    return meta.size();
    }

	public Object get(Object key) {
		if (key != null) {
		    EntityMeta meta = EntityMeta.getInstance(getClass());
		    return meta.get(this,key.toString());
		}
		return null;
    }
	
	public Set<String> keySet() {
		EntityMeta meta = EntityMeta.getInstance(getClass());
	    return meta.keySet();
    }

	public Set<java.util.Map.Entry<String, Object>> entrySet() {
		EntityMeta meta = EntityMeta.getInstance(getClass());
	    return meta.entrySet(this);
    }

	public Collection<Object> values() {
		EntityMeta meta = EntityMeta.getInstance(getClass());
	    return meta.values(this);
    }
	
	public boolean containsValue(Object val) {
	    return values().contains(val);
    }

	public boolean isEmpty() {
	    return false;
    }

	//public void clear() {
    //}

	//public Object put(String key, Object val) {
	//    return null;
    //}

	//public void putAll(Map<? extends String, ? extends Object> all) {
    //}

	//public Object remove(Object key) {
	//    return null;
    //}
}
